$(function () {
    let user = JSON.parse(localStorage.getItem("login"))
    $(".userName").text(user.user)
    // 右侧内容头部文字
    $(".FlLis>li").on({
        click: function () {
            $(".top>img").prop("src", $(this).children("span").children("img").prop("src"))
            $(this).addClass("cut").siblings().removeClass("cut")
            $(".top>span").text($(this).children("span").text())
            if ($(this).index() > 0) {
                $(".choose,.buys").hide()
            } else {
                $(".choose,.buys").show()
            }
        },mouseenter:function (){
            $(this).addClass("cut1")
        },
        mouseleave:function (){
            $(this).removeClass("cut1")
        }
    })

    // 订单信息
    let teaCar = JSON.parse(localStorage.getItem("teaCar"))
    let login = JSON.parse(localStorage.getItem("login"))
    let strLis
    $(".buys").empty()
    for (const k in teaCar) {
        if (teaCar[k].user === login.user) {
            let allMoney = teaCar[k].bill * teaCar[k].num
            strLis = `
            <li>
                <div class="buyTop">
                    <p>订单：<span>${teaCar[k].listNum}</span>状态：<span>${teaCar[k].state}</span>日期：<span>${teaCar[k].date}</span></p>
                    <p>合计：<span>￥${allMoney}.0</span></p>
                </div>
                <div class="butinfo">
                    <img src="${teaCar[k].img}" alt="">
                    <p>
                        <span class="infoName">${teaCar[k].name}</span><span class="unitMoney">${teaCar[k].bill}0</span>
                        <span class="infoNum">×${teaCar[k].num}</span><span class="allMoney">￥${teaCar[k].bill}</span>
                    </p>
                </div>
                <div class="buyBut"> <button>查看</button></div>
            </li>
            `
            $(".buys").append(strLis)
        }
    }
    if(teaCar===null){
        teaCar=[]
    }
    if (teaCar.length < 8) {
        $(".page").hide()
    } else {
        $(".page").show()
    }
})